package org.ting.book.mapper;

import org.apache.ibatis.annotations.*;
import org.ting.book.model.BookInfo;

import java.util.List;
//todo 接口
@Mapper
public interface BookMapper {
    @Select("select * from book_info")
    List<BookInfo> getBookList();

    @Insert("insert into book_info(book_name, author, publish, price, count, total, status) " +
            "values(#{bookName}, #{author}, #{publish}, #{price}, #{count}, #{total}, #{status})")
    Integer insertBook(BookInfo book);

    @Select("select * from book_info where id = #{bookId}")
    BookInfo getBookById(Integer bookId);

    @Delete("delete from book_info where id = #{id}")
    Integer deleteBookById(Integer id);

    @Update("update book_info set book_name = #{bookName}, author = #{author}, publish = #{publish}," +
            " price = #{price}, count = #{count}, total = #{total}, status = #{status}" +
            " where id = #{id}")
    Integer updateBook(BookInfo book);
}
